package com.nikkerball.apps.darkhorse.model.evaluation.base;

import com.nikkerball.apps.darkhorse.model.base.ValueObject;
import com.nikkerball.apps.darkhorse.model.change.ChangeEvent;
import com.nikkerball.apps.darkhorse.model.change.ChangeValue;
import com.nikkerball.apps.darkhorse.model.core.Learner;
import com.nikkerball.apps.darkhorse.model.evaluation.EvaluationPeriod;

import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.util.List;

/**
 * Represents an Evaluation
 *
 * @author marius (created on 2010-12-05)
 */
@MappedSuperclass
public class Evaluation extends ValueObject {

    // ----- instance fields -----

    private EvaluationPeriod evaluationPeriod;

    private Learner learner;

    private String status;

    // ----- constructors -----

    public Evaluation() {
        super();
    }

    public Evaluation(EvaluationPeriod evaluationPeriod, Learner learner) {
        this.evaluationPeriod = evaluationPeriod;
        this.learner = learner;
    }

    // ----- public methods -----

    @Transient
    public List<ChangeValue> getChangeValues(ChangeEvent changeEvent) {
        List<ChangeValue> changeValues = super.getChangeValues(changeEvent);
        changeValues.add(new ChangeValue("status", getStatus(), changeEvent));
        return changeValues;
    }

    @ManyToOne
    @JoinColumn(name = "evaluationPeriod_Id", nullable = false)
    public EvaluationPeriod getEvaluationPeriod() {
        return this.evaluationPeriod;
    }

    public void setEvaluationPeriod(EvaluationPeriod evaluationPeriod) {
        this.evaluationPeriod = evaluationPeriod;
    }

    @ManyToOne
    @JoinColumn(name = "learner_Id", nullable = false)
    public Learner getLearner() {
        return this.learner;
    }

    public void setLearner(Learner learner) {
        this.learner = learner;
    }

    @Column(nullable = false)
    public String getStatus() {
        return this.status;
    }

    public void setStatus(String status) {
        this.status = status;
    }


}
